package com.xin.service.impl;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xin.entity.STeacherRole;
import com.xin.mapper.STeacherRoleDao;
import com.xin.service.STeacherRoleService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 用户角色表 服务实现类
 * </p>
 *
 * @author l1
 * @since 2017-12-05
 */
@Service
public class STeacherRoleServiceImpl extends ServiceImpl<STeacherRoleDao, STeacherRole> implements STeacherRoleService {


    @Override
    public JSONArray initRoleList() {
        List<STeacherRole> roles = baseMapper.selectList(null);
        JSONArray result = new JSONArray();
        roles.forEach(role->{
            JSONObject roleJSON = new JSONObject();
            roleJSON.put("id",role.getId());
            roleJSON.put("pId",0);
            roleJSON.put("name",role.getRoleName());
            result.add(roleJSON);
        });
        return result;
    }
}
